Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX(server): Stale user pointers in whisper cache #6372

Merged

Conversation

Krzmbrzl
Copy link
Member

@Krzmbrzl Krzmbrzl commented Apr 1, 2024

Since the whisper cache entry was computed while holding the read-lock,
it was possible for a user in that cache to get deleted while the voice
thread drops the read lock in order to upgrade it to a write lock. In
such a case, the cache entry would contain an invalid (stale) user
pointer, which can lead to crashes when using the cache later on.

By moving the cache entry computation into the block in which we already
hold a read lock, we turn computing the cache and adding it to the cache
store into an atomic operation. As soon as the cache entry is in the
store, deleting a user is no longer an issue as that will implicitly
clear all whisper caches (thereby preventing stale cache entries).

Additionally, the cache creation has been factored out into its own function (for improved readability)

Checks

Since the whisper cache entry was computed while holding the read-lock,
it was possible for a user in that cache to get deleted while the voice
thread drops the read lock in order to upgrade it to a write lock. In
such a case, the cache entry would contain an invalid (stale) user
pointer, which can lead to crashes when using the cache later on.

By moving the cache entry computation into the block in which we already
hold a read lock, we turn computing the cache and adding it to the cache
store into an atomic operation. As soon as the cache entry is in the
store, deleting a user is no longer an issue as that will implicitly
clear all whisper caches (thereby preventing stale cache entries).
Krzmbrzl added 2 commits April 6, 2024 16:51
This should improve the readability of the whisper code path in the
important processMsg function.
Switch to using an unsigned integer as channel ID and rename member
variables to no longer include their type as part of the name (and make
names more meaningful in general).

Additionally, some Qt containers were replaced with std ones.
@Krzmbrzl Krzmbrzl force-pushed the fix-invalid-whisper-target-cache branch from d066fa3 to b7a46b2 Compare April 6, 2024 14:59
@Krzmbrzl Krzmbrzl merged commit 80a1796 into mumble-voip:master Apr 6, 2024
15 checks passed
@Krzmbrzl
Copy link
Member Author

Krzmbrzl commented Apr 6, 2024

💚 All backports created successfully

Status Branch Result
1.5.x

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

Hartmnt added a commit that referenced this pull request Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants